﻿using UnityEngine;
using System.Collections;

public class Gun : Equipable {
    public int attackRange;
    public int Damage;
    public int Ammmo;
    public AudioClip NoAmmo;
    public Gun(int AttackRange,int damage , AudioClip clip, AudioClip equip, Texture texture, int ammo) {
        base.EquipSound = equip;
        Image = texture;
        Sound = clip;
        Damage = damage;
        attackRange = AttackRange;
        type = TypeOfItem.Gun;
        Ammmo = ammo;
    }
    public override int Use(Vector3 pos)
    {
        base.Use(pos);
        return 0;
    }
    public void Shoot(Vector3 pos) {
        if (type == TypeOfItem.DefaultGun) {
			if (Sound) {
				AudioSource.PlayClipAtPoint (Sound, pos);
			}
			return;
		} else {
			if (Ammmo > 0) {
				Ammmo--;
				if (Sound) {
					AudioSource.PlayClipAtPoint (Sound, pos);
				}
			} else if (NoAmmo) {
				AudioSource.PlayClipAtPoint (NoAmmo, pos);
			}
		}
    }
}
